package entities;

import java.io.Serializable;
import java.util.List;

import javax.persistence.*;

/**
 * The persistent class for the user database table.
 * 
 */
@Entity
@Table(name = "user")
public class User implements Serializable {
	private static final long serialVersionUID = 1L;
	private String idUser;
	private String password;
	private String role;
	private List<Employee> employees;
	private List<PatientDetail> patientDetails;

	public User() {
	}

	public User(String idUser, String password, String role) {
		super();
		this.idUser = idUser;
		this.password = password;
		this.role = role;
	}

	@Id
	@Column(unique = true, nullable = false, length = 50)
	public String getIdUser() {
		return this.idUser;
	}

	public void setIdUser(String idUser) {
		this.idUser = idUser;
	}

	@Column(nullable = false, length = 50)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(nullable = false, length = 20)
	public String getRole() {
		return this.role;
	}

	public void setRole(String role) {
		this.role = role;
	}

	// bi-directional many-to-one association to Employee
	@OneToMany(mappedBy = "user")
	public List<Employee> getEmployees() {
		return this.employees;
	}

	public void setEmployees(List<Employee> employees) {
		this.employees = employees;
	}

	// bi-directional many-to-one association to PatientDetail
	@OneToMany(mappedBy = "user", fetch = FetchType.EAGER)
	public List<PatientDetail> getPatientDetails() {
		return this.patientDetails;
	}

	public void setPatientDetails(List<PatientDetail> patientDetails) {
		this.patientDetails = patientDetails;
	}

	@Override
	public String toString() {
		return this.getClass().getName() + "[ " + idUser + " | " + password + " | " + role + " ]";
	}

}